﻿<%@ Page Title="" Language="C#" EnableEventValidation="false" MasterPageFile="~/Portal/Master/Portal.Master" AutoEventWireup="true" CodeBehind="OrderList.aspx.cs" Inherits="Besture.UI.Portal.UserCenter.OrderList" %>

<%@ Import Namespace="Besture.Common.Helper" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="/Resource/css/member.css" rel="stylesheet" />
    <style type="text/css">
        .listwrap {width: auto !important;}
        .tab_content .itme_content > td {width: 80px;}
        .tab_content .itme_content .td7 {width: 90px !important;}
        .date_selector {top: auto !important;}
    </style>
    <script type="text/javascript">   
        //全选
        function selectAll(checkbox) {
            $('input[type=checkbox]').prop('checked', $(checkbox).prop('checked'));
        }
        function GetTabInLoad() {
                  
            //tab切换
            var tab = $(".tab");
            var tabBtn = tab.children("a:not(.more)");
            var tabTarget = $(tab.attr("target"));
            tabTarget.children().hide().first().show();
            tabBtn.each(function (i) {
                if (i == 0) $(this).addClass("active");
                $(this).click(function () {
                    $(this).addClass("active").siblings().removeClass("active");
                    tabTarget.children().eq(i).show().siblings().hide();
                    return false;
                });
            });

            $(".tab a").each(function () {
                var v = parseInt($('#<%=hidID.ClientID%>').val());
                   $(this).parent().find("a:eq(" + v + ")").addClass("active").siblings().removeClass("active");
                   $(".tab" + (v + 1) + "content").show().siblings().hide();
               }); 

            //点击【查询】按钮 后触发 tab 下 botton 事件
            $(".operation a").click(function () {
                var v = $(".tab").find(".active").attr("tabindex");
                $(".tab" + v + "content").show().siblings().hide();
                $(".tab" + v + "content").find("span input").click();
            });

            // 下拉框 事件
            $(".state select").change(function () {
                $(this).parents(".tab_title").prev().find("input").click();
            });

        };
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Content" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <div class="wrap">
                <div class="main member ">
                    <div class="vipbanner"></div>
                    <div class="container">
                        <div class="layout_side">
                            <div class="side_nav">
                                <cms:UserNav runat="server" ID="UserNav" />
                            </div>
                        </div>
                        <div class="layout_main">
                            <div class="vipcon">
                                <div class="viptitle">全部订单</div>
                                <div class="tab" target=".listwrap">
                                    <a href="#" tabindex="1">全部订单&nbsp;<%=AspNetPager1.RecordCount  %></a><a href="#" tabindex="2">待入住&nbsp;<label id="lblOrder2" runat="server"></label></a>
                                    <a href="#" tabindex="3">待评价&nbsp;<label id="lblOrder3" runat="server"></label></a>
                                </div>
                                <div class="operation">
                                    订单号<input type="text" id="txtOrderName" runat="server" />
                                    旅客<input type="text" id="txtContactName" runat="server" placeholder="中文名/英文名" />
                                    预定日期<input type="text" class="date_input" id="txtStartCreateTime" runat="server" onfocus="WdatePicker({minDate:'%y-%M-{%d+1}',maxDate:'#F{$dp.$D(\'txtEndCreateTime\',{d:0});}'})" />
                                    -<input type="text" class="date_input" id="txtEndCreateTime" runat="server" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'txtStartCreateTime\',{d:0});}'})" />
                                    <a href="javascript:void(0)">查询</a>
                                </div>
                                <div class="listwrap">
                                    <%--全部订单--%>
                                    <div class="tab1content">
                                        <span style="display: none">
                                            <asp:Button ID="btnSeach" runat="server" Text="查询" CssClass="btnSeach" OnClick="BtnSeachClick" />
                                        </span>
                                        <!--标题-->
                                        <table class="tab_title">
                                            <tr>
                                                <td style="width: 130px;">
                                                    <label>
                                                        <input type="checkbox" onclick="selectAll(this);"  class="all" />全选</label>
                                                    <a href="javascipt:void(0);" class="del">删除</a>
                                                </td>
                                                <td>房型
                                                </td>
                                                <td>旅客
                                                </td>
                                                <td class="td_date">下单日期
                                                </td>
                                                <td class="count">总金额
                                                </td>
                                                <td class="state">
                                                    <asp:DropDownList ID="ddlOrderStatus1" runat="server"></asp:DropDownList>
                                                </td>
                                                <td class="edit">操作
                                                </td>
                                            </tr>
                                        </table>

                                        <cms:Repeater ID="rpOrder" runat="server">
                                            <ItemTemplate>
                                                <table class="tab_content">
                                                    <tr class="item_title">
                                                        <td colspan="7">
                                                            <label>
                                                                <input type="checkbox" class="itme_all" tabindex="<%#Eval("ID") %>" /></label>
                                                            <a href="javaScript:void(0);" class="item_del" tabindex="<%#Eval("ID") %>">删除订单</a>
                                                            <span class="oid">订单号：<span class="num"><%#Eval("OrderNo") %></span></span><span class="date">预定日期：<%#Eval("CreateTime") %></span></td>
                                                    </tr>
                                                    <tr class="itme_content">
                                                        <td class="td1">
                                                            <a href="/Portal/Hotel/ProductDetail.aspx?hotelid=<%#Eval("HotelsID") %>"><%#Eval("HotelsName") %></a>
                                                        </td>
                                                        <td><%#Eval("RoomName") %>
                                                        </td>
                                                        <td>
                                                            <%#Eval("ContactName") %>
                                                        </td>
                                                        <td style="width: 103px; text-align: center;"><%#Eval("CreateTime") %>
                                                        </td>
                                                        <td class="td5">￥<%#Eval("CopePrice") %></td>
                                                        <td class="td6">
                                                            <span>
                                                                <%#Eval("OrderStatusName") %> 
                                                            </span>
                                                            <br />
                                                            <a href="OrderDetail.aspx?id=<%#Eval("ID") %>">订单详情</a>
                                                        </td>
                                                        <td class="td7">
                                                             
                                                             <%# Eval("OrderStatus").ToString() == "3"? string.Format("<a class='pay' href='/Portal/Pay/OrderPay.aspx?OrderID={0}' >支&nbsp;付</a>",Eval("ID")) :""  %>
                                                            
                                                             <%# Eval("OrderStatus").ToString() == "4" ? GetReviewsReplyByHotelsId(Eval("HotelsID").ToString(),Eval("DepartureDate").ToString()):""  %>

                                                            <span <%# (Convert.ToDateTime(Eval("CheckDate")) >= DateTime.Now.AddDays(-3)
                                                                   && Convert.ToDateTime(Eval("DepartureDate")) <= DateTime.Now) 
                                                                   && (Convert.ToInt32(Eval("OrderStatus").ToString()) < 4) ? "style='display:block'":"style='display:none'" %>>
                                                                <a href="javascript:void(0);" class="send_email">已担保订单入住前三天无法更改</a>
                                                                <img src="/Resource/images/tan.png" />
                                                            </span>
                                                            <span <%# (Convert.ToDateTime(Eval("CheckDate")) >= DateTime.Now.AddDays(-3)
                                                                   && Convert.ToDateTime(Eval("DepartureDate")) <= DateTime.Now) 
                                                                   && Convert.ToInt32(Eval("OrderStatus").ToString()) < 4 ? "style='display:block'":"style='display:none'" %>>
                                                                <a href="mailto:<%#Eval("ContactEmail") %>" class="send_email">点击更改即发送邮件到操作人邮箱</a>
                                                                <a href="mailto:<%#Eval("ContactEmail") %>" class="update">更改</a>
                                                                <a href="javascript:void(0);" class="update">取消</a>
                                                                <a href="mailto:<%#Eval("ContactEmail") %>" class="email"><%#Eval("ContactEmail") %></a>
                                                            </span>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </ItemTemplate>
                                        </cms:Repeater>

                                        <div class="page">
                                            <!-- 分页 -->
                                            <cms:AspNetPager ID="AspNetPager1" AlwaysShow="true" runat="server" NextPageText="下一页" CssClass="page"
                                                ShowFirstLast="true" ShowInputBox="Never" PrevPageText="上一页" PageSize="5" NumericButtonCount="10"
                                                OnPageChanging="AspNetPager1PageChanging">
                                            </cms:AspNetPager>
                                            <!-- /分页 -->
                                        </div>
                                        <br class="clear" />
                                    </div>
                                    <%--待入住--%>
                                    <div class="tab2content">
                                        <span style="display: none">
                                            <asp:Button ID="btnSeach2" runat="server" Text="查询" OnClick="BtnSeach2Click" />
                                        </span>
                                        <table class="tab_title">
                                            <tr>
                                                <td style="width: 130px;">
                                                    <label>
                                                        <input type="checkbox" class="all" onclick="selectAll(this);" />全选</label>
                                                    <a href="javascipt:void(0);" class="del">删除</a>
                                                </td>
                                                <td>房型
                                                </td>
                                                <td>旅客
                                                </td>
                                                <td class="td_date">下单日期
                                                </td>
                                                <td class="count">总金额
                                                </td>
                                                <td class="state">
                                                    <asp:DropDownList ID="ddlOrderStatus2" runat="server"></asp:DropDownList>
                                                </td>
                                                <td class="edit">操作
                                                </td>
                                            </tr>
                                        </table>
                                        <cms:Repeater ID="rpOrder2" runat="server">
                                            <ItemTemplate>
                                                <table class="tab_content">
                                                    <tr class="item_title">
                                                        <td colspan="7">
                                                            <label>
                                                                <input type="checkbox" class="itme_all" /></label>
                                                            <a href="javaScript:void(0);" class="item_del" tabindex="<%#Eval("ID") %>">删除订单</a>
                                                            <span class="oid">订单号：<span class="num"><%#Eval("OrderNo") %></span></span><span class="date">预定日期：<%#Eval("CreateTime") %></span></td>
                                                    </tr>
                                                    <tr class="itme_content">
                                                        <td class="td1">
                                                            <a href="/Portal/Hotel/ProductDetail.aspx?hotelid=<%#Eval("HotelsID") %>"><%#Eval("HotelsName") %></a>
                                                        </td>
                                                        <td><%#Eval("RoomName") %>
                                                        </td>
                                                        <td>
                                                            <%#Eval("ContactName") %>
                                                        </td>
                                                        <td style="width: 103px; text-align: center;"><%#Eval("CreateTime") %>
                                                        </td>
                                                        <td class="td5">￥<%#Eval("CopePrice") %></td>
                                                        <td class="td6">
                                                            <span><%#Eval("OrderStatusName") %></span>
                                                            <br />
                                                            <a href="OrderDetail.aspx?id=<%#Eval("ID") %>">订单详情</a>
                                                        </td>
                                                        <td class="td7">
                                                             <%# Eval("OrderStatus").ToString() == "3"? string.Format("<a class='pay' href='/Portal/Pay/OrderPay.aspx?OrderID={0}' >支&nbsp;付</a>",Eval("ID")) :""  %>
                                                            <%# Eval("OrderStatus").ToString() == "4" ? GetReviewsReplyByHotelsId(Eval("HotelsID").ToString(),Eval("DepartureDate").ToString()):""  %>
                                                            <span <%# (Convert.ToDateTime(Eval("CheckDate")) >= DateTime.Now.AddDays(-3)
                                                                   && Convert.ToDateTime(Eval("DepartureDate")) <= DateTime.Now) 
                                                                   && (Convert.ToInt32(Eval("OrderStatus").ToString()) < 4) ? "style='display:block'":"style='display:none'" %>>
                                                                <a href="javascript:void(0);" class="send_email">已担保订单入住前三天无法更改</a>
                                                                <img src="/Resource/images/tan.png" />
                                                            </span>
                                                            <span <%# (Convert.ToDateTime(Eval("CheckDate")) >= DateTime.Now.AddDays(-3)
                                                                   && Convert.ToDateTime(Eval("DepartureDate")) <= DateTime.Now) 
                                                                   && Convert.ToInt32(Eval("OrderStatus").ToString()) < 4 ? "style='display:block'":"style='display:none'" %>>
                                                                <a href="mailto:<%#Eval("ContactEmail") %>" class="send_email">点击更改即发送邮件到操作人邮箱</a>
                                                                <a href="mailto:<%#Eval("ContactEmail") %>" class="update">更改</a>
                                                                <a href="javascript:void(0);" class="update">取消</a>
                                                                <a href="mailto:<%#Eval("ContactEmail") %>" class="email"><%#Eval("ContactEmail") %></a>
                                                            </span>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </ItemTemplate>
                                        </cms:Repeater>
                                        <br class="clear" />
                                    </div>
                                    <%--待评价--%>
                                    <div class="tab3content">
                                        <span style="display: none">
                                            <asp:Button ID="btnSeach3" runat="server" Text="查询" OnClick="BtnSeach3Click" />
                                        </span>
                                        <!--标题-->
                                        <table class="tab_title">
                                            <tr>
                                                <td style="width: 130px;">
                                                    <label>
                                                        <input type="checkbox" class="all" onclick="selectAll(this);" />全选</label>
                                                    <a href="javascipt:void(0);" class="del">删除</a>
                                                </td>
                                                <td>房型
                                                </td>
                                                <td>旅客
                                                </td>
                                                <td class="td_date">下单日期
                                                </td>
                                                <td class="count">总金额
                                                </td>
                                                <td class="state">
                                                    <asp:DropDownList ID="ddlOrderStatus3" runat="server"></asp:DropDownList>
                                                </td>
                                                <td class="edit">操作
                                                </td>
                                            </tr>
                                        </table>
                                        <cms:Repeater ID="rpOrder3" runat="server">
                                            <ItemTemplate>
                                                <table class="tab_content">
                                                    <tr class="item_title">
                                                        <td colspan="7">
                                                            <label>
                                                                <input type="checkbox" class="itme_all" /></label>
                                                            <a href="javaScript:void(0);" class="item_del" tabindex="<%#Eval("ID") %>">删除订单</a>
                                                            <span class="oid">订单号：<span class="num"><%#Eval("OrderNo") %></span></span><span class="date">预定日期：<%#Eval("CreateTime") %></span></td>
                                                    </tr>
                                                    <tr class="itme_content">
                                                        <td class="td1">
                                                            <a href="/Portal/Hotel/ProductDetail.aspx?hotelid=<%#Eval("HotelsID") %>"><%#Eval("HotelsName") %></a>
                                                        </td>
                                                        <td><%#Eval("RoomName") %>
                                                        </td>
                                                        <td>
                                                            <%#Eval("ContactName") %>
                                                        </td>
                                                        <td style="width: 103px; text-align: center;"><%#Eval("CreateTime") %>
                                                        </td>
                                                        <td class="td5">￥<%#Eval("CopePrice") %></td>
                                                        <td class="td6">
                                                            <span><%#Eval("OrderStatusName") %></span>
                                                            <br />
                                                            <a href="OrderDetail.aspx?id=<%#Eval("ID") %>">订单详情</a>
                                                        </td>
                                                        <td class="td7">
                                                            
                                                              <%# Eval("OrderStatus").ToString() == "3"? string.Format("<a class='pay' href='/Portal/Pay/OrderPay.aspx?OrderID={0}' >支&nbsp;付</a>",Eval("ID")) :""  %>
                                                            <%# Eval("OrderStatus").ToString() == "4" ? GetReviewsReplyByHotelsId(Eval("HotelsID").ToString(),Eval("DepartureDate").ToString()):""  %>
                                                            <span <%# (Convert.ToDateTime(Eval("CheckDate")) >= DateTime.Now.AddDays(-3)
                                                                   && Convert.ToDateTime(Eval("DepartureDate")) <= DateTime.Now) 
                                                                   && (Convert.ToInt32(Eval("OrderStatus").ToString()) < 4) ? "style='display:block'":"style='display:none'" %>>
                                                                <a href="javascript:void(0);" class="send_email">已担保订单入住前三天无法更改</a>
                                                                <img src="/Resource/images/tan.png" />
                                                            </span>
                                                            <span <%# (Convert.ToDateTime(Eval("CheckDate")) >= DateTime.Now.AddDays(-3)
                                                                   && Convert.ToDateTime(Eval("DepartureDate")) <= DateTime.Now) 
                                                                   && Convert.ToInt32(Eval("OrderStatus").ToString()) < 4 ? "style='display:block'":"style='display:none'" %>>
                                                                <a href="mailto:<%#Eval("ContactEmail") %>" class="send_email">点击更改即发送邮件到操作人邮箱</a>
                                                                <a href="mailto:<%#Eval("ContactEmail") %>" class="update">更改</a>
                                                                <a href="javascript:void(0);" class="update">取消</a>
                                                                <a href="mailto:<%#Eval("ContactEmail") %>" class="email"><%#Eval("ContactEmail") %></a>
                                                            </span>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </ItemTemplate>
                                        </cms:Repeater>
                                        <br class="clear" />
                                    </div>
                                </div>

                            </div>
                        </div>
                        <br class="clear" />
                    </div>
                </div>
                <!-- //main -->
                <br class="clear" />
            </div>
            <input type="hidden" id="hidID" runat="server" value="0" />   
            <script type="text/javascript">
                $(function () {

                    //多选择 删除
                    $(".del").click(function () {
                        var vDel = "";
                        $(this).parents(".tab1content").find("label input:checked").each(function () {
                            vDel += $(this).attr("tabindex")+",";
                        });
                        $.ajax({
                            type: "GET",
                            url: "/Portal/UserCenter/OrderList.aspx",
                            data: {
                                delId: vDel.trim()
                    },
                            success: function (data) {
                                if (data.length > 0) {
                                    alert("删除成功");
                                    window.location.href = "/Portal/UserCenter/OrderList.aspx";
                                } else {
                                    alert("删除失败");
                                }
                            }
                        });
                    });
                          
                    // 单选 删除
                    $(".item_title").find(".item_del").click(function () {
                        var vDelId = $(this).attr("tabindex");
                        $.ajax({
                            type: "GET",
                            url: "/Portal/UserCenter/OrderList.aspx",
                            data: {
                                delId: vDelId
                        },
                            success: function (data) {
                                if (data.length > 0) {
                                    alert("删除成功");
                                    window.location.href = "/Portal/UserCenter/OrderList.aspx";
                                } else {
                                    alert("删除失败");
                                }
                            }
                        });
                    });
                         

                    //点击【查询】按钮 后触发 tab 下 botton 事件
                    $(".operation a").click(function () {
                        var v = $(".tab").find(".active").attr("tabindex");
                        $(".tab" + v + "content").show().siblings().hide();
                        $(".tab" + v + "content").find("span input").click();
                    });   
                    $(".state select").change(function () {
                        $(this).parents(".tab_title").prev().click();
                    }); 
                    GetTabInLoad();
                });
            </script>

        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnSeach" />
            <asp:AsyncPostBackTrigger ControlID="btnSeach2" />
            <asp:AsyncPostBackTrigger ControlID="btnSeach3" />
            <asp:AsyncPostBackTrigger ControlID="ddlOrderStatus1" />
            <asp:AsyncPostBackTrigger ControlID="ddlOrderStatus2" />
            <asp:AsyncPostBackTrigger ControlID="ddlOrderStatus3" />
        </Triggers>
    </asp:UpdatePanel>
</asp:Content>
